function bciCheckFeaturesEcog(run,varargin)

global GLOBALbci;
global GLOBALtrainDat;

params.tapers = GLOBALbci.param.tapers;
params.fpass=[1 100];
params.trialave=0; 

for k=1:2:length(varargin),
    if strcmp(varargin{k},'tapers'),
        params.tapers = varargin{k}+1;
    end    
    if strcmp(varargin{k},'fpass'),
        params.fpass = varargin{k}+1;
    end    
end

ecog = bciRawdata2Ecog(run);

params.Fs=1000/ecog.sampDur;


% Make Segments
windowOnsetIdx=GLOBALtrainDat{run}.trainOnset;
windowLength=GLOBALbci.init.nWinLength; % that's in samples
windowLabel=GLOBALtrainDat{run}.trainLabel;
tmpDat=ecog.data;

% loop over channels
for k=1:size(tmpDat,1),
    if ~any(ecog.selectedChannels==k), continue; end        
    ecog.data=tmpDat(k,:);
    [ecogSeg]=ecogSegmentTS(ecog,windowOnsetIdx,0,windowLength);
    ecogSeg1=ecogSeg;
    ecogSeg1.data=single(ecogSeg.data(:,:,find(windowLabel==1)));
    ecogSeg2=ecogSeg;
    ecogSeg2.data=ecogSeg.data(:,:,find(windowLabel==2));
    ecogSeg3=ecogSeg;
    ecogSeg3.data=ecogSeg.data(:,:,find(windowLabel==3));
    % periodograms
    ecogSeg1=ecogMkPeriodogramMultitaper(ecogSeg1,1,params);
    ecogSeg2=ecogMkPeriodogramMultitaper(ecogSeg2,1,params);
    ecogSeg3=ecogMkPeriodogramMultitaper(ecogSeg3,1,params);
    % periodogram to data field
    ecogSegP1=ecogRaw2Ecog(log(1e20*permute(ecogSeg1.periodogram.periodogram,[2 1 3])),0,1000*diff(ecogSeg1.periodogram.centerFrequency(1:2)),[]);
    ecogSegP2=ecogRaw2Ecog(log(1e20*permute(ecogSeg2.periodogram.periodogram,[2 1 3])),0,1000*diff(ecogSeg2.periodogram.centerFrequency(1:2)),[]);
    ecogSegP3=ecogRaw2Ecog(log(1e20*permute(ecogSeg3.periodogram.periodogram,[2 1 3])),0,1000*diff(ecogSeg3.periodogram.centerFrequency(1:2)),[]);
    if ~exist('pT1Vs2','var'),
        pT1Vs2=zeros(size(tmpDat,1),size(ecogSegP1.data,2));
        pT3Vs2=zeros(size(tmpDat,1),size(ecogSegP1.data,2));
        pT1Vs3=zeros(size(tmpDat,1),size(ecogSegP1.data,2));
    end
    % get t-values
    pT1Vs2(k,:)=ecogTValues(ecogSegP1,ecogSegP2);
    pT3Vs2(k,:)=ecogTValues(ecogSegP3,ecogSegP2);
    pT1Vs3(k,:)=ecogTValues(ecogSegP1,ecogSegP3);    
end


figure; 
imagesc(abs(pT1Vs2));
xlabel('Frequency [Hz]');
title('1 vs 2');
ylabel('Channel #');
colormap copper
colorbar

xTL={int2str(round(ecogSeg1.periodogram.centerFrequency(str2num(get(gca,'xticklabel'))))')};
set(gca,'xticklabel',xTL);

figure; 
imagesc(abs(pT3Vs2));
xlabel('Frequency [Hz]');
title('3 vs 2');
ylabel('Channel #');
set(gca,'xticklabel',xTL);
colormap copper
colorbar

figure; 
imagesc(abs(pT1Vs3));
xlabel('Frequency [Hz]');
title('1 vs 3');
ylabel('Channel #');
set(gca,'xticklabel',xTL);
colormap copper
colorbar
